#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START cross-grub
# depends: xz-native


save_CFLAGS="$CFLAGS"
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
export CFLAGS='-O2 -g'
export CPPFLAGS="-I${xtools}${build_prefix}/include"
export LDFLAGS="-L${xtools}${build_prefix}/lib"

reset_mtime grub grub/configure.ac
rm -rf build/cross-grub
mkdir -p build/cross-grub
cd build/cross-grub
cat > config.cache <<-EOF
ac_cv_path_PYTHON=''
ac_cv_path_XGETTEXT=''
ac_cv_path_GMSGFMT=''
ac_cv_path_MAKEINFO=/bin/true
ac_cv_pathless_PYTHON=''
am_cv_pathless_PYTHON=''
EOF

../../grub/configure \
	--host="$BUILD" \
	--build="$BUILD" \
	--target="$TARGET" \
	--prefix="${build_prefix}" \
	--program-transform-name="s,grub,${TARGET}-grub," \
	--disable-werror \
	${AUTOCRAP_KLUDGE}

cd ../..
make_native_build build/cross-grub

export CFLAGS="$save_CFLAGS"
export CPPFLAGS="$save_CPPFLAGS"
export LDFLAGS="$save_LDFLAGS"

# RECIPE END cross-grub
